/*
 * @Date: 2022-01-28 08:27:42
 * @LastEditTime: 2022-01-28 08:47:38
 */
import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

// 导入i18n
// import i18n from '@/lang'
// 全局注册 导入component里面的index.js里面的组件
import component from '@/components'
Vue.use(component)

// 导入mixin检查文件
import checkPermission from '@/mixin/checkPermission'
Vue.mixin(checkPermission)

// 注册自定义事件
// import a from '@/directives'
// alert(a)
import * as directives from '@/directives'
// Object.keys 【遍历】取出对象里面键 拼成数组 forEach遍历数组 给每一个键 自定义指令注册
// directives里面的 就是 指令名和一个对象的组合
// 好处 里面很多个自定义指令 两行代码完成注册
Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key])
})

// 注册过滤器
import * as filter from '@/filters'
Object.keys(filter).forEach(key => {
  Vue.filter(key, filter[key])
})

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// Vue.use({
//   install(Vue, component) {
//     console.log(Vue)
//   }
// }) // 打印是一个Vue实例

// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI, {
//   i18n: (key, value) => i18n.t(key)
// })

new Vue({
  el: '#app',
  router,
  store,
  // i18n,
  render: h => h(App)
})
